package com.dao;

import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.entity.AttachmentEntity;

@Repository
public class AttachmentDaoImpl extends GenericDaoImpl<AttachmentEntity>
		implements AttachmentDao {

	public AttachmentEntity getAttachmentById(Integer id) {
		return getById(AttachmentEntity.class, id);
	}

	public List<AttachmentEntity> getAllAttachments() {
		return getAll(AttachmentEntity.class);
	}

	public AttachmentEntity getAttachmentByUniqueId(String id) {
		String hql = "From AttachmentEntity where id =:id";
		Query query = sessionFactory.getCurrentSession().createQuery(hql);
		query.setParameter("id", id);
		return (AttachmentEntity) query.uniqueResult();
	}

}
